#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/12/18 23:01
# @Author  : lizhen
# @Site    : 
# @File    : cAbstractFactory.py
# @Software: PyCharm


class A1:
    def do(self, other):
        other.do()


class A2:
    def do(self):
        pass


class AFactory:
    def make_charactor(self):
        return A1()

    def make_obstacle(self):
        return A2()


class B1:
    def do(self, other):
        other.do()


class B2:
    def do(self):
        pass


class BFactory:
    def make_charactor(self):
        return B1()

    def make_obstacle(self):
        return B2()


class AbstarctFactoryDemo:
    def __init__(self, factory):
        self.character = factory.make_charactor()
        self.obstacle = factory.make_obstacle()

    def interact(self):
        self.character.do(self.obstacle)

    @classmethod
    def _test_run(cls):
        """
        AbstarctFactoryDemo._test_run()
        """
        af = AFactory()
        af1 = cls(af)
        af1.interact()
        bf = BFactory()
        af12 = cls(bf)
        af12.interact()


if __name__ == '__main__':
    AbstarctFactoryDemo._test_run()
